import React from "react";
import Field from './Field';
export default class App extends React.Component{
    username=React.createRef()
    password=React.createRef()
    render(){
        return(
            <div>
                <h2>用户登录</h2>
                <Field label="用户名" type="text" ref={this.username}/>
                <Field label="密码" type="password" ref={this.password}/>
                <button onClick={()=>{console.log(this.username.current.state.value,this.password.current.state.value)}}>登陆</button>
                <button onClick={()=>{this.username.current.clear();this.password.current.clear()}}>清空</button>
            </div>
        )
    }
}